/*
 * worker.h
 *
 *  Created on: Jan 24, 2012
 *      Author: marco
 */

#ifndef WORKER_H_
#define WORKER_H_

typedef struct user{
	char *name;
	char *pwd;
	pthread_t *tid;
	int sfd;
	int pending;
}user;

typedef struct user_list_node{
	user *user;
	struct user_list_node *next;

}user_list_node;

#define LOGIN_OK 0
#define WRONG_PWD 1
#define ALREADY_CONN 2

#define OK 0
#define WR_START 1
#define WR_DEST 2
#define SERVER_ERR -1


#define WRONG_START "Errore, città di partenza errata!"
#define WRONG_DEST "Errore, città di arrivo errata!"
#define SERVER_ERROR "Errore da parte del server nella gestione della richiesta inoltrata"


#define LLABEL 128

#define EXIT 1
#define OFFER 2
#define REQ 3


void* worker_start(void*);
void worker_stop(void);

int user_check(char *, char *,user **);
user* new_user(user_list_node *, char *, char *);

int offer(char *);
int request(char *);


/*Gestori dei segnali*/
static void worker_sigpipe_handler(int);
static void worker_sigusr1_handler(int);


#endif /* WORKER_H_ */
